/**
 * 
 */
package com.org.bu.app.core;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;

import com.Ostermiller.util.CSVParser;

/**
 * @author vk
 * 
 */
public class OCSVParser {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		OCSVParser csvParser = new OCSVParser();
		
		File inputFile = new File("C:\\workspace\\mod-Ostermiller\\data\\TEST.csv");
		
		String[][] output = csvParser.processFile(inputFile);

		System.out.println("Size=" + output.length);
	}

	public String[][] processFile(File inputFile){
		String[][] output = new String[][]{};
		try {
			long start = System.currentTimeMillis();
			
			FileInputStream fileInputStream = new FileInputStream(inputFile);
			BufferedReader br = new BufferedReader(new InputStreamReader(fileInputStream));
			String buffer = "";
			String reader = "";
			while((buffer = br.readLine()) != null){
				reader = reader + buffer +"\n";
			}
			output =  CSVParser.parse(reader);
			
			long end = System.currentTimeMillis();
			System.out.println(end - start + " msec");
		} catch (Exception e) {
			// TODO: handle exception
		}		
		
		return output;
	}
}
